package com.allianz.webapps.secondController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.common.CustomerContextHolder;
import com.allianz.webapps.https.interfaces.type001.pojo.User;
import com.allianz.webapps.service.MDRTDetailService;

@Controller
@RequestMapping(value="/mdrt")
public class MDRTDetailController {

	@Autowired
	MDRTDetailService   mdrtService;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
	SimpleDateFormat sdfS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	/**
	 * 查询MDRT信息
	 * @param jsonParam
	 * @param session
	 * @return
	 * @throws ParseException 
	 */
	@ResponseBody
	@RequestMapping(value="/getMDRTList")
	public  Map<String,Object>  getList(@RequestParam(value="jsonParam",required=false)String jsonParam,HttpSession session) throws ParseException{
		Map<String,Object> map = new HashMap<String,Object>();
		 User user = (User) session.getAttribute("username");
		 long agentId = Long.parseLong(user.getAgentId());
		 CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_ALLIANZ);
		 List<String> listStr=mdrtService.queryMDRTYear(agentId);
		 CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_ALLIANZ);
		 String  str = mdrtService.queryMdrtCloseDate();
		 map.put("mdrtList", listStr);
		 map.put("closeDate", sdf.format(sdfS.parse(str)));
		return map;
	}
}
